import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Student {
	public Student(String name, float grade, float gpa) {
		super();
		this.name = name;
		this.grade = grade;
		this.gpa = gpa;
	}

	public String name;
	public float grade;
	public float gpa;

	public static void main(String[] args) {

		List<Student> students = new ArrayList<Student>() {
			{
				add(new Student("Tom Cruse", 96.3f, 4.2f));
				add(new Student("Kevin Spacey", 87.2f, 3.1f));
				add(new Student("Will Smith", 92.1f, 3.9f));
				add(new Student("Angelina Jolie", 87.2f, 3.4f));
				add(new Student("Kate Winslet", 89.4f, 4.0f));
			}
		};

		Collections.sort(students, comparator);

		System.out.println("Name\t\t\tGrade\tGPA\n========================================");
		for (Student s : students)
			System.out.printf("%s\t\t%.2f\t%.2f\n", s.name, s.grade, s.gpa);
	}

	private final static Comparator comparator = new Comparator<Student>(){  
        @Override  
        public int compare(Student s1, Student s2) {  
            int cr = 0;  
            float g = s2.grade - s1.grade;  
            if(g != 0)  
                cr = (g>0)?3:-1;  
            else{  
                g = s2.gpa - s1.gpa;  
                if(g != 0)  
                    cr = (g>0)?2:-2;  
            }  
            return cr;  
        }
	};
}
